home *** CD-ROM | disk | FTP | other *** search
- head 1.5;
- branch ;
- access ;
- symbols sprited:1.5.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.5
- date 90.09.11.14.27.19; author kupfer; state Exp;
- branches 1.5.1.1;
- next 1.4;
-
- 1.4
- date 88.07.28.17.18.12; author ouster; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.07.25.14.12.36; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.07.20.18.12.09; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.06.10.16.23.32; author ouster; state Exp;
- branches ;
- next ;
-
- 1.5.1.1
- date 91.12.02.19.54.11; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.5
- log
- @Use function prototypes. Lint.
- @
- text
- @/*
- * StdioFileReadProc.c --
- *
- * Source code for the "StdioFileReadProc" procedure, which is used
- * internally by the stdio library to flush buffers for streams
- * associated with files and other OS-supported streams.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/stdio/RCS/StdioFileReadProc.c,v 1.4 88/07/28 17:18:12 ouster Exp Locker: kupfer $ SPRITE (Berkeley)";
- #endif not lint
-
- #include "stdio.h"
- #include "fileInt.h"
- #include "stdlib.h"
- #include <errno.h>
- #include <unistd.h>
-
- /*
- *----------------------------------------------------------------------
- *
- * StdioFileReadProc --
- *
- * This procedure is invoked when another character is needed
- * from a stream and the buffer is empty. It's used for all
- * streams that are associated with files (or pipes, or anything
- * for which the file-related system calls apply).
- *
- * Results:
- * None.
- *
- * Side effects:
- * If the stream is readable, a bunch of new bytes are read into
- * stream's buffer and readCount is set to indicate how many
- * bytes there are. The error and end-of-file fields in stream
- * are set if any problems occur.
- *
- * If the stream is stdin, then any line-buffered file streams
- * are flushed.
- *
- *----------------------------------------------------------------------
- */
-
- void
- StdioFileReadProc(stream)
- register FILE *stream; /* Stream whose buffer needs filling. The
- * stream must be readable. The clientData
- * field of stream gives a Sprite stream index.
- */
- {
- register FILE * stream2;
-
- /*
- * Before doing any input from stdin, flush line-buffered
- * streams.
- */
-
- if (stream == stdin) {
- for (stream2 = stdioFileStreams; stream2 != NULL;
- stream2 = stream2->nextPtr) {
- if (stream2->flags & STDIO_LINEBUF) {
- fflush(stream2);
- }
- }
- }
-
- /*
- * Create buffer space for this stream if there isn't any yet.
- */
-
- if (stream->bufSize == 0) {
- stream->bufSize = BUFSIZ;
- stream->buffer = (unsigned char *) malloc((unsigned) stream->bufSize);
- }
-
- stream->readCount = read((int) stream->clientData, (char *) stream->buffer,
- stream->bufSize);
- stream->lastAccess = stream->buffer - 1;
- if (stream->readCount <= 0) {
- if (stream->readCount == 0) {
- stream->flags |= STDIO_EOF;
- } else {
- stream->readCount = 0;
- stream->status = errno;
- }
- }
- }
- @
-
-
- 1.5.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/stdio/RCS/StdioFileReadProc.c,v 1.5 90/09/11 14:27:19 kupfer Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.4
- log
- @More lint.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: StdioFileReadProc.c,v 1.3 88/07/25 14:12:36 ouster Exp $ SPRITE (Berkeley)";
- d26 1
- @
-
-
- 1.3
- log
- @Lint.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: StdioFileReadProc.c,v 1.2 88/07/20 18:12:09 ouster Exp $ SPRITE (Berkeley)";
- d81 1
- a81 1
- stream->buffer = (unsigned char *) malloc(stream->bufSize);
- @
-
-
- 1.2
- log
- @Change file streams so that fdopen can be called more than once
- for a given stream id, and get separate buffers.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: StdioFileReadProc.c,v 1.1 88/06/10 16:23:32 ouster Exp $ SPRITE (Berkeley)";
- a59 1
- int i;
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: atoi.c,v 1.1 88/04/28 17:20:23 ouster Exp $ SPRITE (Berkeley)";
- d68 2
- a69 5
- for (i = 1; i < stdioNumFileStreams; i++) {
- stream2 = stdioFileStreams[i];
- if (stream2 == NULL) {
- continue;
- }
- @
-